﻿using System;
using System.Collections.Generic;
using UnityEngine;

namespace UFrame
{
    public class Poly2DTool
    {
        /// <summary>
        /// 求出任意多边形面积,通关传入多边形编辑，顺时针和逆时针顶点.
        /// </summary>
        /// <param name="points"></param>
        /// <returns></returns>
        private double ComputePolygonArea(List<Vector2> points)
        {
            int count = points.Count;
            if (count < 3)
                return 0.0;

            double s = 0;
            for (int i = 0; i < count; ++i)
            {
                s += points[i].x * points[(i + 1) % count].y - points[i].y * points[(i + 1) % count].x;
            }

            return Math.Abs(s / 2.0);
        }

    }
}